package logrus.beanmock.invoker;

public class Counter {

    public Counter(final int minCount, final int maxCount) {
        this.minCount = minCount;
        this.maxCount = maxCount;
    }

    public void inc() {
        count++;
        if (count > maxCount) {
            throw new IllegalStateException("Unexpected invocation");
        }
    }

    private final int minCount;

    private final int maxCount;

    private int count;

    public boolean isValid() {
        return count >= minCount && count <= maxCount;
    }

    public boolean isFinished() {
        return count >= maxCount;
    }
}
